<template>
    <div>
        <h1>这是B组件</h1>
        {{ bNum }}
        <button @click="bButton">点击</button>
    </div>
</template>

<script setup lang="ts">
import { inject } from 'vue';
let bNum: any = inject('key') 
const bButton = () => {
    bNum.value = bNum.value + 1
}
</script>